package Check;

public class SuperArray {
    private  Object [] objects=new Object[0] ;
    public void add(Object value){
        Object [] newObjects =new Object[objects.length+1];
        for(int i=0;i<objects.length;i++){
            newObjects[i]=objects[i];
        }
        newObjects[newObjects.length-1]=value;
        objects=newObjects;

    }

    public Object[] getObjects() {
        return objects;
    }

    public void setObjects(Object[] objects) {
        this.objects = objects;
    }

    public void  remove (int index){
        Object[] newObjects=new Object[objects.length-1];
        for(int i=0;i<newObjects.length;i++){
            if(i<index){
                newObjects[i]=objects[i];
            }
            else{
                newObjects[i]=objects[i+1];
            }
        }
        objects=newObjects;

    }
    public  Object get(int index){
        return objects[index];

    }
    public int size(){
        return objects.length;
    }
    public static void main(String[]args){
        SuperArray ary=new SuperArray();
        ary.add("hello");
        ary.add(120);
        ary.add(20.2);
//
//
        ary.remove(2);
        System.out.println(ary.size());
        System.out.println(ary.get(1));
        for(int i=0;i<ary.size();i++){
            System.out.println(ary.get(i));
        }
    }
}
